home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / programming / libraries / curses210.lha / src / _doecho.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-02-22  |  3.6 KB  |  117 lines

  1. /* -*-C-*-
  2.  *
  3.  *
  4.  * Filename : _doecho.c
  5.  *
  6.  * Author   : Simon J Raybould.    (sie@fulcrum.bt.co.uk).
  7.  *
  8.  * Date     : Friday 23rd August 1991.
  9.  *
  10.  * Desc     : Echos one character.
  11.  *
  12.  *
  13.  * THIS CODE IS NOT PUBLIC DOMAIN
  14.  * ==============================
  15.  * 
  16.  * This code is copyright Simon J Raybould 1991, all rights are reserved.
  17.  * All code, ideas, data structures and algorithms remain the property of the
  18.  * author. Neither the whole nor sections of this code may be used as part
  19.  * of other code without the authors consent. If you wish to use some of this
  20.  * code then please email me at (sie@fulcrum.bt.co.uk).
  21.  *
  22.  * This source is not public domain, so you do not have any right to alter it
  23.  * or sell it for personal gain. The source is provided purely for reference
  24.  * purposes. You may re-compile the source with any compiler you choose.
  25.  * You must not distribute altered copies without the authors consent. My
  26.  * intention is that the source will help people isolate any bugs much more
  27.  * effectivly.
  28.  *
  29.  * Disclaimer
  30.  * ==========
  31.  *
  32.  * No implication is made as to this code being fit for any purpose at all.
  33.  * I (the author) shall not be held responsible for any loss of data or damage 
  34.  * to property that may result from its use or misuse.
  35.  *
  36.  *
  37.  * Revision History
  38.  * ================
  39.  *
  40.  * $Log: _doecho.c,v $
  41.  * Revision 1.6  1993/05/17  23:33:10  sie
  42.  * Underscores added to names.
  43.  * Changes for version 2.10
  44.  *
  45.  * Revision 1.5  1992/12/25  21:37:27  sie
  46.  * Fixed font calculations.
  47.  * Was previously hard coded for topaz 8.
  48.  *
  49.  * Revision 1.4  92/06/10  23:45:10  sie
  50.  * Added serial support.
  51.  * 
  52.  * Revision 1.3  91/12/30  10:31:24  sie
  53.  * Removed LRLine and LRATTRS.
  54.  * The speed increase caused by them was too insignificant.
  55.  * 
  56.  * Revision 1.2  91/12/28  14:02:00  sie
  57.  * Removed WinStat.
  58.  * Renamed LineElement as lnel.
  59.  * 
  60.  * Revision 1.1  91/09/07  11:52:57  sie
  61.  * Initial revision
  62.  * 
  63.  *
  64.  */
  65.  
  66. static char *rcsid = "$Header: /SRC/lib/curses/src/RCS/_doecho.c,v 1.6 1993/05/17 23:33:10 sie Exp $";
  67.  
  68. #include "acurses.h"
  69.  
  70.  
  71. void _DoEcho(WINDOW *WinPtr, char c)
  72. {
  73.   short x, y;
  74.   char Buffer[ANSIBUFSIZ];
  75.   
  76.   if(c == BS || c == CR)        /* Don't echo Backspace or Return */
  77.     return;
  78.  
  79.   if(_CursesType == CUST_CURSES) {
  80.     x = _CursorCol * _FontWidth;
  81.     y = _FontBase + _CursorLine * _FontHeight;
  82.     _ZapCursor();
  83.     SetDrMd(_RPort, JAM2);
  84.     SetAPen(_RPort, WinPtr->_attrs & A_CLRPART);
  85.     Move(_RPort, x, y);
  86.     Text(_RPort, &c, 1);
  87.     _DrawCursor();
  88.   } else {
  89.     _ANSIMove(_CursorLine, _CursorCol);
  90.     if(WinPtr->LnArry[_CursorLine].ATTRS[_CursorCol] & A_ATRPART) {
  91.       sprintf(Buffer, "\033[0;%d;40m", WinPtr->LnArry[_CursorLine].ATTRS[_CursorCol] & A_CLRPART+30);
  92.       if(WinPtr->LnArry[_CursorLine].ATTRS[_CursorCol] & A_BOLD)
  93.     Buffer[2] = '1';
  94.       if(WinPtr->LnArry[_CursorLine].ATTRS[_CursorCol] & A_UNDERLINE)
  95.     Buffer[2] = '4';
  96.       if(WinPtr->LnArry[_CursorLine].ATTRS[_CursorCol] & A_STANDOUT)
  97.     Buffer[2] = '7';
  98.       write(1, Buffer, strlen(Buffer));
  99.     }
  100.     fputc(c, stdout);
  101.     if(WinPtr->LnArry[_CursorLine].ATTRS[_CursorCol] & A_ATRPART)
  102.       write(1, "\033[0m", 4);
  103.   }
  104.   /* Update curscr */
  105.   if(WinPtr != curscr) {
  106.     wmove(curscr, _CursorLine, _CursorCol);
  107.     waddch(curscr, c);
  108.   }
  109.   /* Update Line structure */
  110.   WinPtr->LnArry[_CursorLine-WinPtr->_begy].Line[_CursorCol-WinPtr->_begx] = c;
  111.   WinPtr->LnArry[_CursorLine-WinPtr->_begy].ATTRS[_CursorCol-WinPtr->_begx] = WinPtr->_attrs;
  112.   /* Move current position one to the right */
  113.   if(++WinPtr->_curx > WinPtr->_maxx)
  114.     WinPtr->_curx = WinPtr->_maxx;
  115.   mvcur(_CursorLine, _CursorCol, _CursorLine, _CursorCol + 1);
  116. }
  117.